<!-- Begin: Wrapper Header -->
<div class="header hidden">
    <? Shell::showWidgets('wrapper-header') ?>
</div> <!-- End -->

<!-- Begin: Sidebar Left -->
<div class="sidebar left">
    <? Shell::showWidgets('sidebar-left') ?>                
</div> <!-- End -->

<!-- Begin: Content Search Result -->
<div class="content search-result">
    <div class="header"><h1>Resultado da Busca</h1></div>
    <div class="banners-lateral">
        <span>Publicidade</span>
        <ul>
            <?
            if (isset(LayoutPage::$banners['lateral2'])):
                $banners = LayoutPage::$banners['lateral2'];
                foreach ($banners as $banner):
                    if ($banner == null):
                        ?>
                        <li>
                            <a href="javascript:;">
                                <img src="<?= _BNN_IMG_ ?>lateral2.jpg" alt="Banner" />
                            </a>
                        </li>
                        <?
                    else:
                        ?>
                        <li>
                            <?
                            if (strtolower(pathinfo($banner->filepicture, PATHINFO_EXTENSION)) == 'jpg'):
                                if (!$banner->id_enterprise):
                                    ?>
                                    <a href="<?= $banner->href ?>" target="<?= $banner->target ?>">
                                    <? else: ?>
                                        <a href="<?= __BASE_URI__ . 'revenda/' . urlencode(strtolower(str_replace(' ', '-', $banner->fancyname))) . '/' . $banner->e_id ?>">
                                        <? endif ?>
                                        <img src="<?= _BNN_IMG_ . $banner->filepicture ?>" alt="Banner" />
                                    </a>
                                <? else: ?>
                                    <object width="120" height="60">
                                        <param name="src" value="<?= _BNN_IMG_ . $banner->filepicture ?>">
                                        <param name="wmode" value="opaque">
                                        <embed src="<?= _BNN_IMG_ . $banner->filepicture ?>" width="120" height="60"></embed>
                                    </object>
                                    <? if (!$banner->id_enterprise): ?>
                                        <a class="flash" href="<?= $banner->href ?>" target="<?= $banner->target ?>"></a>
                                    <? else: ?>
                                        <a class="flash" href="<?= __BASE_URI__ . 'revenda/' . urlencode(strtolower(str_replace(' ', '-', $banner->fancyname))) . '/' . $banner->e_id ?>"></a>
                                    <?
                                    endif;
                                endif;
                                ?>
                        </li>
                    <?
                    endif;
                endforeach;
            endif
            ?>
        </ul>
    </div>
    <p class="announce">Há <strong><?= SearchResult::$pagination->num_rows ?></strong> anúncios de veículos que atendem a sua busca:</p>
    <? if (!empty(SearchResult::$data)): ?>
        <a href="<?= __BASE_URI__ ?>comparativo" class="button-comparative"><img src="<?= _IMG_ ?>comparative.png"></a>
    <? endif; ?>
    <div class="pages-menu">
        <?= SearchResult::$pagination->html ?>
    </div>
    <div class="pagination">
        <? if (!empty(SearchResult::$data)): ?>
            <ul>
                <?
                $n = 0;
                foreach (SearchResult::$data as $vehicle):
                    if ($n++ == 3):
                        if (isset(LayoutPage::$banners['search'])):
                            $banner = LayoutPage::$banners['search'];
                            if ($banner == null):
                                ?>
                                <a class="banner" href="javascript:;" target="Banner">
                                    <img src="<?= _BNN_IMG_ ?>search.jpg" alt="Banner" />
                                </a>
                                <?
                            else:
                                if (strtolower(pathinfo($banner->filepicture, PATHINFO_EXTENSION)) == 'jpg'):
                                    if (!$banner->id_enterprise):
                                        ?>
                                        <a class="banner" href="<?= $banner->href ?>" target="<?= $banner->target ?>">
                                        <? else: ?>
                                            <a class="banner" href="<?= __BASE_URI__ . 'revenda/' . urlencode(strtolower(str_replace(' ', '-', $banner->fancyname))) . '/' . $banner->e_id ?>">
                                            <? endif ?>
                                            <img src="<?= _BNN_IMG_ . $banner->filepicture ?>" alt="Banner" />
                                        </a>
                                    <? else: ?>
                                        <object class="banner" width="627" height="100">
                                            <param name="src" value="<?= _BNN_IMG_ . $banner->filepicture ?>">
                                            <param name="wmode" value="opaque">
                                            <embed src="<?= _BNN_IMG_ . $banner->filepicture ?>" width="627" height="100"></embed>
                                        </object>
                                        <? if (!$banner->id_enterprise): ?>
                                            <a class="flash" href="<?= $banner->href ?>" target="<?= $banner->target ?>"></a>
                                        <? else: ?>
                                            <a class="flash" href="<?= __BASE_URI__ . 'revenda/' . urlencode(strtolower(str_replace(' ', '-', $banner->fancyname))) . '/' . $banner->e_id ?>"></a>
                                        <?
                                        endif;
                                    endif;
                                endif;
                            endif;
                        endif
                        ?>
                        <li>
                            <h1>

                                <span><a href="javascript:;" title="Comparar Veículos" class="add-comparative <? if (in_array($vehicle->v_id, $_SESSION['vehicle_comparative'])): ?> checked <? endif; ?>" rel="<?= $vehicle->v_id ?>"></a>Cód: <?= str_pad($vehicle->v_id, 6, 0, 0) ?></span>
                                <a href="<?= __BASE_URI__ . urlencode(strtolower($vehicle->t_name)) . '/' . urlencode(strtolower($vehicle->m_name)) . '/' . urlencode(strtolower($vehicle->b_name)) . '/' . $vehicle->firstreg . '/' . $vehicle->v_id ?>">

                                    <?= $vehicle->m_name . ' ' . $vehicle->version . ' ' . $vehicle->c_name . ' ' . $vehicle->firstreg ?>
                                </a>
                            </h1>
                            <div>
                                <a href="<?= __BASE_URI__ . urlencode(strtolower($vehicle->t_name)) . '/' . urlencode(strtolower($vehicle->m_name)) . '/' . urlencode(strtolower($vehicle->b_name)) . '/' . $vehicle->firstreg . '/' . $vehicle->v_id ?>">
                                    <img class="thumb" src="<?= _VHC_IMG_ ?>search/<?= $vehicle->vtop_filename ?>" alt="" />
                                </a>
                                <p>
                                    <?= $vehicle->t_name . ' - ' . $vehicle->m_name . ' ' . $vehicle->engine ?><br/>
                                    <?= $vehicle->c_name . ' - ' . $vehicle->firstreg . '/' . $vehicle->modelyear . ' - ' . $vehicle->f_name ?><br/>
                                    <?= $vehicle->ctoc_name . $vehicle->ctoe_name . '/' . $vehicle->stoc_name . $vehicle->stoe_name ?>
                                </p>
                                <? if ($vehicle->ctoc_name != null): ?>
                                    <span class="private">Veículo Particular</span>
                                <? else: ?>
                                    <a href="<?= __BASE_URI__ . 'revenda/' . urlencode(strtolower(str_replace(' ', '-', $vehicle->etp_fancyname))) . '/' . $vehicle->etp_id ?>">
                                        <img class="private" src="<?= _ETP_IMG_ ?>logo/<?= empty($vehicle->filebrand) ? 'no-image.jpg' : $vehicle->filebrand ?>" />
                                        <span class="numvehicles"><?= DbGet::enterprise_vehicles_numrows($vehicle->etp_id) ?> Veículos</span>
                                    </a>
                                <? endif ?>
                                <span class="price">
                                    <span>R$</span> <?= Util::format_money((int) ($vehicle->price - $vehicle->discount), 0) ?><span><?= ltrim(Util::format_money(($vehicle->v_price - $vehicle->discount) - (int) ($vehicle->v_price - $vehicle->discount)), '0') ?></span>
                                </span>
                            </div>
                        </li>
                    <? endforeach ?>
            </ul>
        <? else: ?>
            <p class="notfound">Nenhum veículo foi encontrado</p>
        <? endif ?>
    </div>
    <div class="pages-menu bottom">
        <?= SearchResult::$pagination->html ?>
    </div>
</div> <!-- End -->
